package Ubi.Infrastructure;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;

import android.location.Location;
import Ubi.App.Contact;
import Ubi.App.EventBase;
import Ubi.App.EventMeeting;
import Ubi.App.EventPickUp;
import Ubi.Interfaces.IEventHandler;

public class EventHandler implements IEventHandler
{
	@Override
	public EventMeeting CreateEvent(Location dest, Date date, Contact creator,
			ArrayList<Contact> awaiting) 
	{
		EventMeeting event = new EventMeeting(dest, date, creator, null);
		if(awaiting != null)
		{
			for(Contact invited : awaiting)
			{
				event.AddInvited(invited);
			}
		}
		
		return event;
	}

	@Override
	public EventPickUp CreateEvent(Location dest, Date date, ArrayList<Contact> awaiting,
			Contact picker) 
	{
		EventPickUp event = new EventPickUp(dest, date, picker, picker, null);
		
		if(awaiting != null)
		{
			for(Contact invited : awaiting)
			{
				event.AddInvited(invited);
			}
		}
		
		return event;
	}

	@Override
	public EventPickUp CreateEvent(Location dest, Date date,
			Entry<Contact, Location> creator) 
	{
		Map<Contact, Location> participants = new HashMap<Contact, Location>();
		participants.put(creator.getKey(), creator.getValue());
		EventPickUp event = new EventPickUp(dest, date, creator.getKey(), null, participants);
		
		return event;
	}

	@Override
	public boolean RemoveParticipant(int eventId, Contact toRemove) 
	{
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean CancelEvent(int eventId) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean Update(int eventId, EventBase newEvent) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean TryUpdate(int eventId, EventBase newEvent) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean RespondToInvitation(int eventId, Contact contact,
			boolean response) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public void EventUpdated(EventBase newEvent) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void EventInvitation(EventBase newEvent) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public static int GetNewServerId() {
		// TODO Auto-generated method stub
		return 0;
	}

}
